package cn.doctorpda.conference.presenter;

import cn.doctorpda.conference.bean.Msg;
import cn.doctorpda.conference.config.NetConfig;
import cn.doctorpda.conference.model.GetCollectionDeleteModel;
import cn.doctorpda.conference.model.IPostModel;
import cn.doctorpda.conference.okhttp.callback.StringCallback;
import cn.doctorpda.conference.utils.Exceptions;
import cn.doctorpda.conference.utils.GsonUtil;
import cn.doctorpda.conference.view.callbackview.IRegisterView;
import okhttp3.Call;

/**
 * Created by huangjinlong on 2016/5/19.
 */
public class CollectDeletePresenter {
    private IPostModel model;
    private IRegisterView registerView;

    public CollectDeletePresenter(IRegisterView baseView) {
        model = new GetCollectionDeleteModel();
        registerView = (IRegisterView) baseView;
    }

    public void deleteCollect(String id, String type) {
        model.postNetWorkStringData(NetConfig.GET_COLLECT_DELETE, new StringCallback() {
            @Override
            public void onError(Call call, Exception e) {
                registerView.setRegisterError(call, e);
            }

            @Override
            public void onResponse(String response) {
                try {
                    Msg msg = GsonUtil.fromJson(response, Msg.class);
                    registerView.setRegisterView(msg);
                } catch (Exception e){
                    e.printStackTrace();
                }

            }
        }, id, type);
    }
}
